package com.pswv2.admin.user.action;


import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pswv2.admin.user.service.AdminUserService;
import com.pswv2.bub.bsc.dao.po.AdminUser;
import com.pswv2.bub.bsc.dao.po.User;
import com.pswv2.util.CommonResp;
import com.pswv2.util.ExtraSpringHibernateTemplate;
import com.pswv2.util.Sessions;

@Controller
@RequestMapping(value = "adminUserAction", produces = { "text/json;charset=UTF-8" })
public class AdminUserAction {
	private static Class<?> poc = User.class;
	@Autowired
	private ExtraSpringHibernateTemplate extraSpringHibernateTemplate;
	@Autowired
	private AdminUserService adminUserService;

	/**
	 * 注册账号
	 * @param account
	 * @param password
	 * @param session
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "platformAdd")
	public String platformAdd( String password, String account,HttpSession session) {
		AdminUser toSave = new AdminUser();
		toSave.setPassword(password);
		toSave.setAccount(account);
		extraSpringHibernateTemplate.getHibernateTemplate().save(toSave);
		Sessions.setLoginedUser(toSave,session);
		return CommonResp.buildSuccessResp().toJsonString();
	}
	

}
